package com.liujun.microserver.auth2.implicit.server.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;

/**
 * 授权服务配制
 * 
 * @since 2018年6月24日 下午4:27:49
 * @version 0.0.1
 * @author liujun
 */
@Configuration
@EnableAuthorizationServer
public class Auth2AuthorizeationServer extends AuthorizationServerConfigurerAdapter {

	@Override
	public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
		clients.inMemory()
				// 客户端的名称
				.withClient("clientapp")
				// 客户端安全码
				.secret("112233")
				// 重定向的url
				.redirectUris("http://localhost:9001/callback")
				// 指定为简化模式，不需要通过授权码得到token
				.authorizedGrantTypes("implicit")
				.accessTokenValiditySeconds(120)
				// 细分权限
				.scopes("read_userinfo", "read_contacts");

	}

}
